package com.itheima.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.ZJCReturnvisitDao;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.pojo.ZJCReturnVisit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

@Service(interfaceClass = ZJCReturnvisitService.class)
@Transactional
public class ZJCReturnvisitServiceImpl implements ZJCReturnvisitService {
    @Autowired
    private ZJCReturnvisitDao zjcReturnvisitDao;

    @Override
    public PageResult findByCondition(QueryPageBean queryPageBean) {
        PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        Page<ZJCReturnVisit> page = zjcReturnvisitDao.findByCondition(queryPageBean.getQueryString());
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public void add(ZJCReturnVisit zjcReturnVisit) throws Exception {
        zjcReturnvisitDao.add(zjcReturnVisit);
    }

    @Override
    public void edit(ZJCReturnVisit zjcReturnVisit) throws Exception {
        zjcReturnvisitDao.edit(zjcReturnVisit);
    }

    @Override
    public void delete(Integer id) {
        zjcReturnvisitDao.delete(id);
    }
}
